#!/usr/bin/make -f
#makefile to convert headers using swig
#place in the directory containing C headers you want to translate.
#make SWIG_DATA point to the directory you placed the swig files.
#the example below uses MinGW style paths, equivalent to C:\FreeBASIC
#and requires MSYS on Windows.

ifndef SWIG
	SWIG := wine /home/mud/swig/swig.exe
endif
ifndef SWIG_DATA
	SWIG_DATA := /home/mud/swig/
endif
ifndef SWIG_FLAGS
	SWIG_FLAGS := -I$(SWIG_DATA) -freebasic -module
endif

HEADERS := $(wildcard *.h)
MODULES := $(HEADERS:%.h=%)

all :
	@for i in $(MODULES); do \
	cat $$i.h | sed 's|^#include "cairo-|//#include|g' > $$i.processed.c && gcc -E -c -pipe $$i.processed.c > $$i.complete.c && \
	$(SWIG) $(SWIG_FLAGS) $$i $$i.complete.c 2> swigconvert_errors.txt && \
	rm $$i.processed.c $$i.complete.c mod*.bi && \
	mv $$i.complete.bi $$i.bi; \
	done
